﻿using System.Diagnostics;
using System.IO;
using System.Windows;

namespace DesktopToy;

public partial class App
{
    protected override void OnStartup(StartupEventArgs e)
    {
        StartDesktopToy();
        Current.Shutdown();
    }

    private static void StartDesktopToy()
    {
        var startInfo = new ProcessStartInfo
        {
            UseShellExecute = true,
            FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DesktopToyWpf.exe"),
            Verb = "runas" // 要用管理员启动
        };
        
        try
        {
            Process.Start(startInfo);
        }
        catch (Exception ex)
        {
            MessageBox.Show($"启动 DesktopToyWpf 失败：{ex.Message}");
        }
    }
}